package com.coursedesign.controller;

import com.coursedesign.bean.BannerBean;
import com.coursedesign.bean.SolarTermBean;
import com.coursedesign.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @RequestMapping(value = "/solarTermList" ,method = RequestMethod.GET)
    public Map getSolarTermList(){

        List<SolarTermBean> solarTermList = homeService.getSolarTermList();
        Map<String, Object> data = new HashMap<>();
        if (solarTermList!=null){
            data.put("code","00");
            data.put("msg","成功");
            data.put("list",solarTermList);
        }else {
            data.put("code","88");
            data.put("msg","失败");
        }
       return  data;
    }

    @GetMapping("/bannerList")
    public Map  getBannerList() {
        List<BannerBean> bannerList = homeService.getBannerList();
        Map<String, Object> data = new HashMap<>();
        if (bannerList!=null){
            data.put("code","00");
            data.put("msg","成功");
            data.put("list",bannerList);
        }else {
            data.put("code","88");
            data.put("msg","失败");
        }
        return  data;
    }
}
